package com.hwl.demo11;

import com.hwl.demo11.service.IDepartment;
import com.hwl.demo11.service.IUser;
import com.hwl.demo11.service.impl.AccessDepartment;
import com.hwl.demo11.service.impl.AccessUser;
import com.hwl.demo11.service.impl.SqlserverDepartment;
import com.hwl.demo11.service.impl.SqlserverUser;

/**
 * @author sentry
 * @since 2023-03-19
 */
public class DataAccess {

    private static final String db = "SqlServer";

    public static IUser createUser() {
        IUser result;
        switch (db) {
            case "SqlServer":
                result = new SqlserverUser();
                break;
            case "Access":
                result = new AccessUser();
                break;
            default:
                throw new RuntimeException("不支持");

        }
        return result;
    }

    public static IDepartment createDepartment() {
        IDepartment result;
        switch (db) {
            case "SqlServer":
                result = new SqlserverDepartment();
                break;
            case "Access":
                result = new AccessDepartment();
                break;
            default:
                throw new RuntimeException("不支持");
        }
        return result;
    }
}
